﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using System.IO;
using DXWindowsApplication1.MainForm;


namespace DXWindowsApplication1
{
    public partial class Form1 : RibbonForm
    {
        List<string> history = new List<string>();
        int index = 0;
        TreeViewExplorer treeview = new TreeViewExplorer();
        ListViewExplorer listview = new ListViewExplorer();
        public Form1()
        {            
            InitializeComponent();
            //InitData1();
            tvThuMuc.ImageList = imageList1;
            listView1.SmallImageList = imageList1;
            listView1.LargeImageList = imageList1;
           treeview.buildTree(tvThuMuc);
        }
        

        private void iAbout_ItemClick(object sender, ItemClickEventArgs e)
        {
            string s = "Windows Explorer \n Demo DevExpress";
            MessageBox.Show(s, "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        
        private void tvThuMuc_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node.Nodes[0].Text == "temp")
            {
                treeview.expandTree(e.Node);
            }
        }

        private void tvThuMuc_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string path = listview.OpenFolderOnTreeView(e.Node,listView1);
            textEdit1.Text = path;

            history.Add(textEdit1.Text);
            index = history.Count - 1;

        }

        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewItem item = listView1.FocusedItem;
            textEdit1.Text = listview.OpenFolderOnListview(item, listView1);
            history.Add(textEdit1.Text);
            index = history.Count - 1;
        }

        private void iBack_ItemClick(object sender, ItemClickEventArgs e)
        {
            string path="";
            if ((index -= 1) >= 0)
            {
                path = history[index];
            }
            else {
                index = 0;
                path = history[index];
            }
            textEdit1.Text = listview.OpenFolderBaseOnLink(path,listView1);
        }

        private void iForward_ItemClick(object sender, ItemClickEventArgs e)
        {
            string path = "";
            if ((index += 1) < history.Count)
            {
                path = history[index];
            }
            else { 
                index = history.Count - 1;
                path = history[index];
            }
            textEdit1.Text = listview.OpenFolderBaseOnLink(path, listView1);
        }

 

       

                
    }
}